package al.ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.UIManager;

import org.jdesktop.swingx.JXFrame;
import org.jdesktop.swingx.JXLoginPane;
import org.jdesktop.swingx.JXLoginPane.JXLoginFrame;
import org.jdesktop.swingx.JXLoginPane.Status;

import al.components.AuthentificationService;


public class LoginFrame extends WindowAdapter{
	private JXLoginPane loginPane;
	private JXLoginFrame loginFrame;
	private AuthentificationService as;
	public LoginFrame() {
		super();
		as = new AuthentificationService();
		loginPane = new JXLoginPane(as);
		loginFrame = new JXLoginFrame(loginPane);
		loginFrame.setVisible(true);
		loginFrame.pack();
		loginFrame.setDefaultCloseOperation(JXFrame.EXIT_ON_CLOSE);
		loginFrame.addWindowListener(this);
	}

	public static void main(String[] args) {
		new LoginFrame();
	}

	@Override
	public void windowClosed(WindowEvent e) {
		Status status = loginFrame.getStatus();
		if(status == Status.SUCCEEDED) {
			Principale f = new Principale();
			f.setVisible(true);
			f.pack();
		}
		else {
			loginFrame.setDefaultCloseOperation(JXLoginFrame.EXIT_ON_CLOSE);
		}
	}
}
